cc.Toast = {};
cc.Proxy = {};
cc.Linker = {};
cc.Global = {};
cc.Emitter = {};

window.LangLocal = {};
window.LangPublic = {};

window.BUILD_CONFIG = {
    supportHotUpdate: false,
    useDefaultLanguage: false,
}

window.CONFIG = {
    language: 'en-us',
    appVersion: '1.0.0.0',
    username: '13776103941',
    baseUrl: 'http://47.98.105.238',
    accessToken: 'b30f0c982589470cabee9daa49a5599c',
}

window.LINK = {
    accessToken: null,
    appChannel: cc.sys.os === cc.sys.OS_IOS ? 300001 : 200001,

    uuid: null,
    token: null,
    userID: null,
    userInfo: null,
    isGuestLogin: true,
}

window.EVENTS = {
    GET_TOKEN: 'GET_TOKEN',
    USER_LOGOUT: 'USER_LOGOUT',
    GAME_RESUME: 'GAME_RESUME',
    GAME_RECHARGE: 'GAME_RECHARGE',
    REFRESH_STATE: 'REFRESH_STATE',
    REFRESH_AMOUNT: 'REFRESH_AMOUNT',

    SIGN_AWARD: 'SIGN_AWARD',
    RANK_AWARD: 'RANK_AWARD',
    MENU_POP_STATE: 'MENU_POP_STATE',
    DRAW_BOX_STATE: 'DRAW_BOX_STATE',

    EMAIL_AMOUNT_REFRESH: 'EMAIL_AMOUNT_REFRESH',
    EMAIL_AMOUNT_CHANGE: 'EMAIL_AMOUNT_CHANGE',
}

module.exports = function (data) {

    function getLanguage(language) {
        if (BUILD_CONFIG.useDefaultLanguage)
            return 'en-us';
        var LangsMap = {
            en: ['us'],
            zh: ['tw', 'cn']
        }
        var strs = language.split('-');
        var langs = LangsMap[strs[0]];
        if (langs) {
            return (strs[1] && langs.indexOf(strs[1]) > -1) ? language : (strs[0] + '-' + langs[0]);
        } else {
            return 'en-us';
        }
    }
    CONFIG.baseUrl = data.baseUrl;
    CONFIG.appVersion = data.appVersion;
    CONFIG.language = getLanguage(data.language);
    LangLocal = require('LangLocal-' + CONFIG.language);
    LangPublic = require('LangPublic-' + CONFIG.language);

    window.URL = {
        GameList: CONFIG.baseUrl + '/api_app/api/game/list',
        UserInfo: CONFIG.baseUrl + '/api_app/api/app/usercenter/getUserPersonalInfo',
        SignedAwards: CONFIG.baseUrl + '/api_platform/api/signin/signin',
        ShopList: CONFIG.baseUrl + '/api_platform/api/pay/abroad/normal',
        SaleList: CONFIG.baseUrl + '/api_platform/api/pay/abroad/activityList',
        ShopOrder: CONFIG.baseUrl + '/api_platform/api/order/abroad/normal',
        ShopBought: CONFIG.baseUrl + '/api_platform/api/pay/abroad/showAwardsInfo',
        SaleOrder: CONFIG.baseUrl + '/api_platform/api/order/abroad/activity',
        OrderState: CONFIG.baseUrl + '/api_platform/api/order/abroad/activity',
        ExportShopList: CONFIG.baseUrl + '/api_platform/api/exeunt/goodsList',
        ExportShopOrder: CONFIG.baseUrl + '/api_platform/api/exeunt/placingOrder',
        ExportBoughtList: CONFIG.baseUrl + '/api_platform/api/exeunt/historyOrder',
        ActiveList: CONFIG.baseUrl + '/api_task/api/mission/list',
        ActiveValue: CONFIG.baseUrl + '/api_task/api/mission/liveness/cur',
        ActiveAmount: CONFIG.baseUrl + '/api_task/api/mission/scale',
        ActiveTake: CONFIG.baseUrl + '/api_task/api/mission/liveness/take',
        RankSelf: CONFIG.baseUrl + '/api_platform/api/ranking/flowAmount/self',
        RankReceive: CONFIG.baseUrl + '/api_platform/api/ranking/flowAmount/receivePrize',
        UserAccount: CONFIG.baseUrl + '/api_platform/api/finances/summary/user',
        GameAccount: CONFIG.baseUrl + '/api_platform/api/finances/summary/games',
        ProtectoItem: CONFIG.baseUrl + '/api_arrows/api/finances/details',
        RaceItem: CONFIG.baseUrl + '/api_bike/api/finances/details',
        TroopsItem: CONFIG.baseUrl + '/api_wars/api/finances/details',
        BilliardItem: CONFIG.baseUrl + '/api_billiards/api/finances/details',
        DartsItem: CONFIG.baseUrl + '/api_dart/api/finances/details',
        BuryingPoint: CONFIG.baseUrl + '/api_platform/api/uic/buryingPoint',
        GetUnBettingGameUrl: CONFIG.baseUrl + '/api_task/api/mission/getUnBettingGameUrl',
        RewardsTake: CONFIG.baseUrl + '/api_task/api/mission/scale/take',
        HotActivityList: CONFIG.baseUrl + '/api_platform/api/hotActivity/list',
        IsReadActivity: CONFIG.baseUrl + '/api_platform/api/hotActivity/lookUp',
        EmailList: CONFIG.baseUrl + '/api_platform/api/mail/list',
        EmailDetail: CONFIG.baseUrl + '/api_platform/api/mail/read',
        DeleteEmail: CONFIG.baseUrl + '/api_platform/api/mail/del',
        GetItemFromEmail: CONFIG.baseUrl + '/api_platform/api/mail/take',
        GetEmailAmount: CONFIG.baseUrl + '/api_platform/api/mail/countUnread',
        UserActonPoint: CONFIG.baseUrl + '/api_platform/api/trace',
    }
}